﻿#region using statements

using Microsoft.Xna.Framework;

using NGen.Managers.Logging;

#endregion

namespace NGen.Managers
{
	/// <summary>
	/// 	Abstract class which all managers must inherit in order to be
	/// 	be registered in the game engine
	/// </summary>
	public class GameManager : IGameManager
	{
		#region local fields

		/// <summary>
		/// 	backing variable for DrawOrder property
		/// </summary>
		private int m_drawOrder;

		/// <summary>
		/// 	backing variable for UpdateOrder property
		/// </summary>
		private int m_updateOrder;

		#endregion

		#region public properties

		///<summary>
		///	Order in which this manager should be updated. Higher number gets updated later
		///</summary>
		public int UpdateOrder {
			get { return m_updateOrder; }
			set {
				m_updateOrder = value;
				GameEngine.UpdateOrDrawOrderChanged();
			}
		}

		///<summary>
		///	Order in which this manager should be drawn. Higher number gets drawn on top of lower numbers
		///</summary>
		public int DrawOrder {
			get { return m_drawOrder; }
			set {
				m_drawOrder = value;
				GameEngine.UpdateOrDrawOrderChanged();
			}
		}

		/// <summary>
		/// 	Should this manager skip its update call
		/// </summary>
		public bool SkipUpdate { get; set; }

		/// <summary>
		/// 	Should this manager skips its draw call
		/// </summary>
		public bool SkipDraw { get; set; }

		#endregion

		#region internal methods

		/// <summary>
		/// 	Initialize the manager
		/// </summary>
		internal virtual void Initialize() {}

		/// <summary>
		/// 	Update the manager
		/// </summary>
		/// <param name = "p_gameTime">snapshot of timing values</param>
		internal virtual void Update(GameTime p_gameTime) {}

		/// <summary>
		/// 	Draw the manager
		/// </summary>
		/// <param name = "p_gameTime">snapshot of timing values</param>
		internal virtual void Draw(GameTime p_gameTime) {}

		/// <summary>
		/// 	Cleanup the manager
		/// </summary>
		internal virtual void Cleanup() {}

		#endregion

		#region ILoggableImplementation

		public LoggingLevel CurrentLoggingLevel { get; set; }

		public ILogger Logger { get; set; }

		#endregion
	}
}